package com.example.demo.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

/**
 * Created by wen.gao on 2018/5/6.
 */
@RestController
@RequestMapping("/webflux")
public class WebfluxDemoController {

    // 使用@Value从application.yml加载配置
    @Value("${author.firstName}")
    private String authorFirstName;
    @Value("${author.lastName}")
    private String authorLastName;

    @GetMapping("/hello")
    public Mono<String> helloWebflux(String name) {
        if(name ==null || name.equals("")) {
            name = authorFirstName + "." + authorLastName;
        }
        return Mono.just("hello " + name);
    }
}
